<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String productCode = request.getParameter("productCode");
%>
<script type="text/javascript" charset="utf-8" src="<c:url value='/js/plug/ueditor/ueditor.config.js'/>"></script>
<script type="text/javascript" charset="utf-8" src="<c:url value='/js/plug/ueditor/ueditor.all.js'/>"></script>

<div class="easyui-layout" style="width:100%;height:100%;" fit="true">
    <div data-options="region:'center',title:'',split:true" style="height:100%;">
		<form id="intrductionForm" method="post" >
			<table class="detailTable"> 
			<tr>
                <th>选择展示风格:</th> 
                <td colspan="3">
                	<input type="radio" value="1" name="useType" checked="checked"/>字段形式展示
                	<input type="radio" value="2" name="useType" />富文本形式展示
                </td>
            </tr>
            <tbody id="viewOne">
			<tr>
                <th>商品编号:</th> 
                <td>
                	<input class="easyui-validatebox"  name="productCode" value="<%=productCode %>" data-options="required:true" value="" readonly="readonly">
                </td>
                 <th>成分:</th> 
                <td>
                	<input class="easyui-validatebox"  name="iCompose"   >
                </td>
            </tr>
            <tr>
                <th>性状:</th> 
                <td><input class="easyui-validatebox"  name="iCharacter"  ></td>
            	<th>功能主治:</th> 
                <td><input class="easyui-validatebox"  name="iFunction"  ></td>
            </tr>
            <tr>
                <th>用法用量:</th> 
                <td><input class="easyui-validatebox"  name="iUsage"   ></td>
                <th>不良反应:</th> 
                <td><input class="easyui-validatebox"  name="iBadness"   ></td>
            </tr>
			  <tr>
                <th>禁忌:</th> 
                <td><input class="easyui-validatebox"  name="iTaboo"   ></td>
                <th>注意事项:</th> 
                <td><input class="easyui-validatebox"  name="iNotice"   ></td>
            </tr>
			  <tr>
                <th>药物相互作用:</th> 
                <td><input class="easyui-validatebox"  name="iReciprocity"   ></td>
                <th>贮藏:</th> 
                <td><input class="easyui-validatebox"  name="iStore"  ></td>
            </tr>
            	<tr>
                <th>包装:</th> 
                <td><input class="easyui-validatebox"  name="iPacking"   ></td>
                <th>有效期:</th> 
                <td><input class="easyui-validatebox"  name="iValidity"  ></td>
            </tr>
			<tr>
            	<th>执行标准:</th> 
                <td colspan="3"><input class="easyui-validatebox"  name="iStandard"   ></td>
			</tr>
			</tbody>
			<tbody id="viewTwo" style="display: none;">
				<tr>
	                <td colspan="4">
	                <textarea name="descript" id="descript" style="width:100%; height:300px;"></textarea>
	                </td>
				</tr>
			</tbody>
			<tr>
				<td align="center" colspan="4">
					<input type="button" onclick="submitForm()" class="button" value="提交" >
					<input type="button" onclick="pms.resetForm('intrductionForm')" class="button" value="重置" >
				</td>
			</tr>
		</table>
		</form>
    </div>
</div>  
<script>
$(function(){
	var param = {"productCode":"<%=productCode%>"}
	$.pmsAjax({
		url : '<c:url value="/product/showEmBProductIntroductionDetail.do"/>',
		data : param,
		success : function(data) {
			if(data.code=="200"){
				var ret = data.data.detail;
				$('#intrductionForm').form('load', ret);
				if(ret!=null){
					if(data.data.detail.useType==1){
						$("input[name='useType']").eq(0).click();
					}
					if(data.data.detail.useType==2){
						$("input[name='useType']").eq(1).click();
					}
				}
				UE.getEditor('descript',{serverUrl: '<c:url value="/js/plug/ueditor/jsp/controller.jsp"/>',UEDITOR_HOME_URL:'<c:url value="/js/plug/ueditor/"/>'});
			}else{
				alertError(data.result);
			}
		}
	});


	$("input[name='useType']").click(function(){
		var v = $(this).val();
		if(v==1){
			$("#viewOne").show();
			$("#viewTwo").hide();
		}
		if(v==2){
			$("#viewOne").hide();
			$("#viewTwo").show();
		}
	});
});

function submitForm(){
	$('#intrductionForm').form('submit', {
	    url:'<c:url value="/product/saveOrUpdateProductIntrduction.do"/>',
	    onSubmit: function(param){
	    	if(!$("#intrductionForm").form('validate')){
	    		return false;
	    	}
	    },
	    dataType : 'json',
	    success:function(data){
		    var ret = eval("("+data+")");
	     	if(ret.code=="200"){
	     		alertShow(ret.result);
		    }else{
		    	alertError(ret.result);
			}
	    }
	});
}
</script>
